package ru.spb.osll.myfit.server.execute;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import ru.spb.osll.myfit.fixtures.base.OneLineFixtureUtilsTest;
import fit.Parse;

public class MyFitFixtureListenerTest {
	public MyFitFixtureListener listener;
	static final String SYSTEM_LINE_SEPARATOR = System
			.getProperty("line.separator");
	private static final String HTML = "<table border=\"1\" cellspacing=\"0\">\n"
			+ "<tr><td>dummy one line</td>\n"
			+ "<td>OK</td>\n</tr>\n</table>\n";

	@Before
	public void setUp() {
		listener = new MyFitFixtureListener();
	}

	@Test
	public void testTableFinished() throws Exception {
		Parse table = new Parse(OneLineFixtureUtilsTest
				.wiki2html("|dummy one line|OK|"));
		listener.tableFinished(table);
		String expected = HTML.replace("</td>\n", "</td>"
				+ SYSTEM_LINE_SEPARATOR);
		assertEquals(expected, listener.getOutput());
	}
}
